[ appscript ] Document

FindText in Document

// Get the body section of the active document.
var body = DocumentApp.getActiveDocument().getBody();

// Search until the paragraph is found.
var foundElement = body.findText("Pong:.*?Yesterday")
if(searchResult) {
var par = foundElement.getElement().getText();
var startPosition = foundElement.getStartOffset();
var endPosition = foundElement.getEndOffsetInclusive();
Logger.log("++"+par+"++");
}

ref : https://developers.google.com/apps-script/reference/document/body

[ facebook ] pixel

<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below. 
fbq('init', 'FB_PIXEL_ID');
fbq('track', 'PageView');
</script>
<!-- Insert Your Facebook Pixel ID below. -->
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=FB_PIXEL_ID&amp;ev=PageView&amp;noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

NOTE : change the FB_PIXEL_ID to yours.

To add the standard events and custom events, please refer to the reference below.

ref : https://developers.facebook.com/docs/facebook-pixel/api-reference#

[ facebook ] analytics

  • 77 % customers are lost in the first week
  • 60 % apps are used less than 10 times
  • 77 % People with 3 or more devices start a task on one device and complete on a different device
  • 180 % higher retention when people opt-in to push notification — aka. campaign/weekly deal/daily deal (within 3 months)

Event Javascript API
Overview
– No need facebook login/all people will be tracked action but facebook login will have more deep data aggregation.

* Activate

FB.AppEvents.logPageView();

#### TODO : Pixel example ?

* View Content up to 25 differents Parameters/1000 event types i.e. Content Type, Content ID ( or product id ), Description, Currency, Value, Category
Tips :
– log the 1st most important action to optimize i.e. Purchase
– also log lead-in events that contribute to that goal i.e. add to cart
– free and no limit on number of events logged

* User : Who i.e. user id, install source i.e. twitter, registeration year, loyalty program
– sent CRM data via API
– sent via SDK

* TODO : Share ?
Sharing insight facebook feature

* Search up to 25 differents parameters i.e. Flight

var params = {};
params[FB.AppEvents.ParameterNames.SearchType] = 'Flight';
FB.AppEvents.logEvent(
  FB.AppEvents.EventNames.SEARCHED,
  params
);

NOTE : In addition to the predefined events, you can also create custom events by specifying their name as a string.
FB.AppEvents.logEvent(‘battledAnOrc’);
The maximum length for a custom event name is 40 characters and it can only use characters that are letters, numbers, underscores, or dashes.
You can have a maximum of 1,000 different event names. Note: No new event types will be logged if you reach this maximum level. If you exceed this limit, you’ll see an 100 Invalid parameter error when trying to log new event types. However, you can deactivate any existing events that you may not be using. Learn more about event limits.

* Registered

* Add to cart

* Archieved Level

* Message Sent

* Purchase

FB.AppEvents.logPurchase(578, "USD");

ref : https://analytics.facebook.com/support,

https://developers.facebook.com/docs/analytics/training
Customer case study : https://analytics.facebook.com/customers
Stack Overflow : #Facebook-Analytics
twitter : @fbanalytics

[ rails ] link_to_if

Syntax

link_to_if(condition is true, name, options = {}, html_options = {}, &block)

NOTE : if condition is true, otherwise only the name is returned

link_to_if(it_has_link?, "text to show", "http://google.com", target: '_blank', rel: "http://whatever/rel/url")

ref : http://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/UrlHelper.html