Facebook Analytics

Facebook Analytics

 

View and activate on the Corona Store

This plugin allows you to log events and user info through facebook analytics for iOS and Android

Documentation

added limitEventUsage

https://scotth.tech/plugin-facebookAnalytics

Hi mr. Scott!

I love that you’ve made FB app events available for corona. However, there seems to be an issue with the build settings when building this for iOS. No problem with android. (I’m not yet using any events, just trying to build it with the plugin added to build settings).

Feb 04 01:05:21.062 ERROR: Builder failed: /Users/okkohakola/Desktop/Corona_games_projects/facegame.app/.build/libtemplate/Builder.lua:125: attempt to index local ‘attributes’ (a nil value)
Feb 04 01:05:21.062 BUILD ERROR: There was a problem linking the app.

Log:

Feb 04 01:05:01.630 Using custom build id from app bundle: 00000 (AppSettings.lua) Feb 04 01:05:01.644 2017-02-04 13:05:01.630 Corona Simulator[18014:999929] logEvent: key: target Feb 04 01:05:13.861 BuildID: 589641fd179cc Feb 04 01:05:19.356 Using additional build settings from: build.settings Feb 04 01:05:19.400 Server dir name: facegame.app Server app name: facegame (local name: facegame) Feb 04 01:05:19.425 Building: Copying app resources Feb 04 01:05:19.426 Excluding specified files from build: excluding: Icon-\*dpi.png Feb 04 01:05:19.495 Contents of ZIP file from server: Feb 04 01:05:19.526 facegame.app/ facegame.app/embedded.mobileprovision facegame.app/MainWindow-iPad.nib/ facegame.app/MainWindow-iPad.nib/objects.nib Feb 04 01:05:19.542 facegame.app/MainWindow-iPad.nib/runtime.nib facegame.app/Default-568h@2x.png facegame.app/resource.car facegame.app/PkgInfo facegame.app/CoronaResources.bundle/ facegame.app/CoronaResources.bundle/widget\_theme\_android.png facegame.app/CoronaResources.bundle/widget\_theme\_onOff\_mask.png facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_dark@4x.png facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_light@2x.png facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_light@4x.png facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_light.png facegame.app/CoronaResources.bundle/widget\_theme\_onOff\_mask\_android\_holo.png facegame.app/CoronaResources.bundle/widget\_theme\_ios7@4x.png facegame.app/CoronaResources.bundle/widget\_theme\_ios7.png facegame.app/CoronaResources.bundle/widget\_theme\_ios@2x.png facegame.app/CoronaResources.bundle/widget\_theme\_android@2x.png facegame.app/CoronaResources.bundle/widget\_theme\_pickerWheel\_mask.png facegame.app/CoronaResources.bundle/Info.plist facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_dark.png facegame.app/CoronaResources.bundle/widget\_theme\_ios7@2x.png facegame.app/CoronaResources.bundle/widget\_theme\_android\_holo\_dark@2x.png facegame.app/CoronaResources.bundle/widget\_theme\_ios.png facegame.app/\_CoronaSplashScreen.png facegame.app/Info.plist facegame.app/\_CodeSignature/ facegame.app/\_CodeSignature/CodeResources facegame.app/CoronaSDK3rdPartyLicenses.txt facegame.app/.build/ facegame.app/.build/plugin.CoronaSplashControl/ facegame.app/.build/plugin.CoronaSplashControl/lua/ facegame.app/.build/plugin.CoronaSplashControl/lua/lua\_51/ facegame.app/.build/plugin.CoronaSplashControl/lua/lua\_51/plugin/ facegame.app/.build/plugin.CoronaSplashControl/lua/lua\_51/plugin/CoronaSplashControl.lua facegame.app/.build/libtemplate/ facegame.app/.build/libtemplate/Defaults.lua facegame.app/.build/libtemplate/libtemplate.a facegame.app/.build/libtemplate/Builder.lua facegame.app/.build/libtemplate/build.lua facegame.app/.build/libtemplate/BuilderUtils.lua facegame.app/.build/plugin.facebookAnalytics/ facegame.app/.build/plugin.facebookAnalytics/libplugin\_facebookAnalytics.a facegame.app/.build/plugin.facebookAnalytics/metadata.lua facegame.app/MainWindow.nib/ facegame.app/MainWindow.nib/objects.nib facegame.app/MainWindow.nib/runtime.nib Feb 04 01:05:19.543 Building: Unpacking build from server Feb 04 01:05:20.917 Building: Adding plugins Feb 04 01:05:20.940 builder: buildOptions: { "dstDir":"/Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app", "dstName":"facegame", "dstPath":"/Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/facegame", "librarySearchPaths":["/Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/libtemplate"], "pluginsDir":"/Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build", "settings":{ "splashScreen":{ "enable":true, "image":"splash.png" }, "android":{ "facebookAppId":"1227917163910000", "usesPermissions":["android.permission.INTERNET"] }, "plugins":{ "plugin.CoronaSplashControl":{ "supportedPlatforms":{ "android":true, "iphone":true }, "publisherId":"com.coronalabs" }, "plugin.facebookAnalytics":{ "supportedPlatforms":{ "android":true, "iphone":true, "android-kindle":true }, "publisherId":"tech.scotth" } }, "iphone":{ "plist":{ "UILaunchImages":[{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{320, 480}", "UILaunchImageName":"Default" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{320, 568}", "UILaunchImageName":"Default-568h" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{768, 1024}", "UILaunchImageName":"Default-Portrait" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{375, 667}", "UILaunchImageName":"Default-667h" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{414, 736}", "UILaunchImageName":"Default-736h" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"8.0", "UILaunchImageSize":"{414, 736}", "UILaunchImageName":"Default-736h" },{ "UILaunchImageOrientation":"Portrait", "UILaunchImageMinimumOSVersion":"9.0", "UILaunchImageSize":"{1024, 1366}", "UILaunchImageName":"Default-Portrait-1366" }], "LSApplicationQueriesSchemes":["fb","fbapi","fbauth2","fb-messenger-api","fbshareextension"], "UIPrerenderedIcon":true, "UIStatusBarHidden":false, "MinimumOSVersion":"8.0", "FacebookAppID":"1227917163910000", "UIApplicationExitsOnSuspend":false, "CFBundleIconFiles":["Icon.png","Icon@2x.png","Icon-167.png","Icon-60.png","Icon-60@2x.png","Icon-60@3x.png","Icon-72.png","Icon-72@2x.png","Icon-76.png","Icon-76@2x.png","Icon-Small.png","Icon-Small@2x.png","Icon-Small@3x.png","Icon-Small-40.png","Icon-Small-40@2x.png","Icon-Small-50.png","Icon-Small-50@2x.png"], "CFBundleURLTypes":[{ "CFBundleURLSchemes":["fb1227917163910000"] }] } }, "excludeFiles":{ "android":["Icon.png","Icon-Small-\*.png","Icon\*@2x.png"], "iphone":["Icon-\*dpi.png"] }, "orientation":{ "default":"portrait", "supported":["portrait"] } }, "tmpDir":"/var/folders/gb/sgb9kff117j1plr1s41xxkm40000gn/T/CLtmpGLHrM3", "verbose":0 } Feb 04 01:05:21.061 Analyzing plugins... Feb 04 01:05:21.061 Found native plugin: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.facebookAnalytics Done. Analyzing Lua plugins... Feb 04 01:05:21.062 +++ examining Lua plugin: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.CoronaSplashControl/lua/lua\_51/ Found Lua plugin: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.CoronaSplashControl/lua/lua\_51/ +++ examining Lua plugin: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.facebookAnalytics/lua/lua\_51/ Feb 04 01:05:21.062 ERROR: Builder failed: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/libtemplate/Builder.lua:125: attempt to index local 'attributes' (a nil value) Feb 04 01:05:21.062 BUILD ERROR: There was a problem linking the app. Check the console for more information. Feb 04 01:05:21.104 iOS build failed (12) after 20 seconds Feb 04 01:05:21.419 2017-02-04 13:05:21.418 Corona Simulator[18014:999929] logEvent: key: target 2017-02-04 13:05:21.418 Corona Simulator[18014:999929] logEvent: key: reason Feb 04 01:05:21.419 ERROR: Build Failed: There was a problem linking the app. Check the console for more information.

build.settings

-- -- For more information on build.settings see the Corona SDK Build Guide at: -- https://docs.coronalabs.com/guide/distribution/buildSettings -- settings = { plugins = { ["plugin.facebookAnalytics"] = { publisherId = "tech.scotth", supportedPlatforms = { iphone=true, android=true, ["android-kindle"]=true } }, ["plugin.CoronaSplashControl"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, android=true }, }, }, splashScreen = { enable = true, image = "splash.png" }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", }, }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-167.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, UILaunchImages = { { -- iPhone 4 Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 480}" }, { -- iPhone 5 Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 568}" }, { -- iPad Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-Portrait", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{768, 1024}" }, { -- iPhone 6 Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{375, 667}" }, { -- iPhone 6 Plus Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-736h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPhone 6 Plus Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-736h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPad Pro Portrait ["UILaunchImageMinimumOSVersion"] = "9.0", ["UILaunchImageName"] = "Default-Portrait-1366", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{1024, 1366}" }, }, MinimumOSVersion = "8.0", UIApplicationExitsOnSuspend = false, FacebookAppID = "1227917163910000", CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1227917163910000", } } }, -- Whitelist Facebook apps LSApplicationQueriesSchemes = { "fb", -- Needed for the facebook-v4.isFacebookAppEnabled() API "fbapi", "fbauth2", "fb-messenger-api", "fbshareextension" }, }, }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", }, facebookAppId = "1227917163910000", }, }

What might be wrong there? 

Use an older version, corona has a bug in there newer builds.

You could update the docs to mention that fb analytics replaces the coronas fb plugin. 

Also, update this part: 

publisherId = “com.scottrules44”,  

Thanks for the help! Worked with build 3007

updated

Hi again, Scott!

Is it possible to use this with corona’s facebook plugin?

      [“plugin.facebook.v4”] =

      {

          publisherId = “com.coronalabs”,

          supportedPlatforms = { iphone=true, android=true, [“android-kindle”]=true }

      },

It seems to always fail in building.

duplicate symbol \_OBJC\_METACLASS\_$\_FBSDKMaleSilhouetteIcon in: /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.facebook.v4/libFBSDKCoreKit.a(FBSDKMaleSilhouetteIcon.o) /Users/okkohakola/Desktop/Corona\_games\_projects/facegame.app/.build/plugin.facebookAnalytics/libplugin\_facebookAnalytics.a(FBSDKMaleSilhouetteIcon.o) ld: 508 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) BUILD ERROR: There was a problem linking the app. Check the console for more information. iOS build failed (12) after 17 seconds Feb 06 12:56:53.530 2017-02-06 12:56:53.518 Corona Simulator[2712:72505] logEvent: key: target Feb 06 12:56:53.531 2017-02-06 12:56:53.518 Corona Simulator[2712:72505] logEvent: key: reason Feb 06 12:56:53.531 ERROR: Build Failed: There was a problem linking the app. Check the console for more information.

How would I set up a Facebook login while using your plugin?

it should work with corona plugin on iOS, I might try to include the Facebook plugin with my Facebook analytics plugin. I don’t want to run into trouble with corona legal wise.

Try building without the Facebook plugin, I push an experimental build that has facebook v4 plugin bundled with the Facebook analytics plugin.

Starting today if you are using 2017.3128 or higher the plugin will set the Facebook v4a plugin as a dependency. It is now the recommended Facebook SDK of Corona.

Hi Scott,

My builds are succeeding but when I try to run my app in Xcode simulator I get this error.

Runtime error: module 'plugin.facebookAnalytics' not found:resource (plugin.facebookAnalytics.lu) does not exist in archive

My build.settings and main.lua are set up correctly, I think. If you don’t know of an immediate issue that could be causing this, I’ll post them for you.

Of note, in my console log when I build for the simulator it shows this

Apr 10 22:55:10.182 Analyzing plugins...Apr 10 22:55:10.182 Found native plugin: /Users/craigjanis/Desktop/Playmatic.app/.build/plugin.facebook.v4 Apr 10 22:55:10.183 Found native plugin: /Users/craigjanis/Desktop/Playmatic.app/.build/plugin.flurry.analytics                     Done.                                          Analyzing Lua plugins... Apr 10 22:55:10.183 Examining plugin: plugin.facebook.v4                     Examining plugin: plugin.flurry.analytics                     Examining plugin: plugin.facebookAnalytics                     Done.

It doesn’t show that the facebookAnalytics plugin is found, but it does seem to be “examining” it, whatever that means.

If you believe there is a bug file it here
https://docs.google.com/forms/d/e/1FAIpQLSf-V3z-V3FZ5y9Sb19cxVfjx7fSRV9HIbpAGptN7DaY3Ki_DA/viewform

Ok, I submitted it.

Scott - thanks for making the plugin. The documentation says to use the following require in the lua file:

local facebook = require("plugin.facebook.v4") local facebookAnalytics = require "plugin.facebookAnalytics" facebookAnalytics.init()

But given that Corona now uses v4a. Should that first line be this instead? thx!

local facebook = require( "plugin.facebook.v4a" )

You can use either

I’ve got trouble using custom events and multiple parameters:

Here is the event I tried:

facebookAnalytics.logEvent(“Hello game3”, {myParams = “hello”, myParams2 = 3})

But when I try to make a segment in the facebook console, I can see the first “myParams”, but I can’t see the “myParams2”. Has anyone already tried to use the plugin with multiple parameters?

I’m not quite sure about how to use it. The doc tells :

– params(number)(optional) other params of eventhere(App Event Schema)

But I expected params to be a lua table not a number. What am I missing?

Can you file a bug report

https://docs.google.com/forms/d/e/1FAIpQLSf-V3z-V3FZ5y9Sb19cxVfjx7fSRV9HIbpAGptN7DaY3Ki_DA/viewform

I’ve filled a bug report. Basically, my conclusions after in depth testings are:

-You can’t pass both parameters and a valueToSum in the same event.

-You can’t set parameters value to a number. It only works if it’s a string.

Any news about those bugs? I really need to, at least, be able to send events with a valueToSum and a parameter without this parameter being ignored.

It’s the second event type described in the documentation of the plugin:

facebookAnalytics.logEvent(“Hello world”, 100, {world = “hello”})

But it’s not working. I mean when calling this event, the param world is not sent. I’m sad the plugin sample does not include such event.

Also the fact that parameters cannot be number is annoying to make some decent analytics.

This has been patched